/**Transcore is a remote-GUI to Transmission.
Copyright (C) 2009 by Jerry de Swart

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package transcore;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;

/**
 *
 * @author J de Swart (Custombuild@gmail.com)
 */
public class TransSession {

	private TransConnection conn;
	private DaemonSettings daemonSettings;
	private DaemonStats daemonStats;

	public TransSession(String host, int port, String username, String password) throws URISyntaxException, IOException {
		conn = TransConnection.createTransConnection(host, port, username, password);

		daemonSettings = new DaemonSettings();
		daemonStats = new DaemonStats();

		updateAll();
	}

	public void updateAll() throws IOException {
		daemonSettings.update(conn);
		daemonStats.update(conn);
	}

	//daemonSettings getters
	public String getEncryption() {
		return daemonSettings.getEncryption();
	}

	public String getDownloadDir() {
		return daemonSettings.getDownloadDir();
	}

	public int getSpeedLimitDown() {
		return daemonSettings.getSpeedLimitDown();
	}

	public int getSpeedLimitUp() {
		return daemonSettings.getSpeedLimitUp();
	}

	public int getPeerLimit() {
		return daemonSettings.getPeerLimit();
	}

	public int getPort() {
		return daemonSettings.getPort();
	}

	public Boolean getUseSpeedLimitDown() {
		return daemonSettings.getUseSpeedLimitDown();
	}

	public Boolean getUseSpeedLimitUp() {
		return daemonSettings.getUseSpeedLimitUp();
	}

	public Boolean getPexAllowed() {
		return daemonSettings.getPexAllowed();
	}

	public Boolean getUsePortForwarding() {
		return daemonSettings.getUsePortForwarding();
	}

	public String getTransVersion() {
		return daemonSettings.getTransVersion();
	}

	//daemonStats getters
	public int getTotalTorrents() {
		return daemonStats.getTotalTorrents();
	}

	public int getActiveTorrents() {
		return daemonStats.getActiveTorrents();
	}

	public int getPausedTorrents() {
		return daemonStats.getPausedTorrents();
	}

	public int getDownloadSpeed() {
		return daemonStats.getDownloadSpeed();
	}

	public int getUploadSpeed() {
		return daemonStats.getUploadSpeed();
	}

	public int getCumulativeUploadedBytes(){
		return daemonStats.getCumulativeUploadedBytes();
	}

	public int getCumulativeDownloadedBytes(){
		return daemonStats.getCumulativeDownloadedBytes();
	}

	public int getCumulativeFilesAdded(){
		return daemonStats.getCumulativeFilesAdded();
	}

	public int getCumulativeSessionCount(){
		return daemonStats.getCumulativeSessionCount();
	}

	public int getCumulativeSecondsActive(){
		return daemonStats.getCumulativeSecondsActive();
	}

	public int getCurrentUploadedBytes(){
		return daemonStats.getCurrentUploadedBytes();
	}

	public int getCurrentDownloadedBytes(){
		return daemonStats.getCurrentDownloadedBytes();
	}

	public int getCurrentFilesAdded(){
		return daemonStats.getCurrentFilesAdded();
	}

	public int getCurrentSessionCount(){
		return daemonStats.getCurrentSessionCount();
	}

	public int getCurrentSecondsActive(){
		return daemonStats.getCurrentSecondsActive();
	}

	public HashMap<String, Integer> getDaemonStats() {
		return daemonStats.getDaemonStats();
	}

	public HashMap<String, Object> getDaemonSettings() {
		return daemonSettings.getDaemonSettings();
	}

	public void setDaemonSettings(String encryption, String downloadDir, int speedLimitDown, int speedLimitUp, int peerLimit, int port, Boolean useSpeedLimitDown, Boolean useSpeedLimitUp, Boolean pexAllowed, Boolean usePortForwarding) throws IOException {
		daemonSettings.setDaemonSettings(conn, encryption, downloadDir, speedLimitDown, speedLimitUp, peerLimit, port, useSpeedLimitDown, useSpeedLimitUp, pexAllowed, usePortForwarding);
	}
}
